package com.tiantian.filterandInterceptor.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private HandlerInterceptor01 handlerInterceptor01;
    @Autowired
    private HandlerInterceptor02 handlerInterceptor02;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //1.加入的顺序就是拦截器执行的顺序，
        //2.按顺序执行所有拦截器的preHandle
        //3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
        registry.addInterceptor(handlerInterceptor01)
                .addPathPatterns("/**");
        registry.addInterceptor(handlerInterceptor02)
                .addPathPatterns("/**");

    }
}
